package com.zeta.eduservice.service.impl;

import com.zeta.eduservice.entity.EduTeacher;
import com.zeta.eduservice.entity.excel.QuestionChoiceExcel;
import com.zeta.eduservice.entity.question.EduChapter;
import com.zeta.eduservice.entity.question.EduCoursequestionlistInfo;
import com.zeta.eduservice.entity.question.EduQuestion;
import com.zeta.eduservice.entity.question.EduQuestionChoice;
import com.zeta.eduservice.entity.vo.Ata;
import com.zeta.eduservice.entity.vo.QuestionChoiceVo;
import com.zeta.eduservice.entity.vo.QuestionQuery;
import com.zeta.eduservice.entity.vo.QuestionUploadVo;
import com.zeta.eduservice.entity.vo.TeacherQuery;
import com.zeta.eduservice.listener.UploadQuestionChoiceExcelListener;
import com.zeta.eduservice.listener.UploadQuestionExcelListener;
import com.zeta.eduservice.mapper.EduQuestionChoiceMapper;
import com.zeta.eduservice.service.ChapterAQuestionTypeSysAndChoicequestionService;
import com.zeta.eduservice.service.EduChapterService;
import com.zeta.eduservice.service.EduCoursequestionlistInfoService;
import com.zeta.eduservice.service.EduQuestionChoiceService;
import com.alibaba.excel.EasyExcel;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;

import java.io.IOException;
import java.io.InputStream;
import java.util.List;

import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

/**
 * <p>
 * 选择试题 服务实现类
 * </p>
 *
 * @author zeta
 * @since 2020-10-08
 */
@Service
public class EduQuestionChoiceServiceImpl extends ServiceImpl<EduQuestionChoiceMapper, EduQuestionChoice>
		implements EduQuestionChoiceService {

	@Autowired
	EduCoursequestionlistInfoService eduCoursequestionlistInfoService;
	
	@Override
	public void upload(MultipartFile file,QuestionUploadVo questionUploadVo ,EduQuestionChoiceService choiceService,ChapterAQuestionTypeSysAndChoicequestionService chapterAQuestionTypeSysAndChoicequestionService )
			throws IOException {
		InputStream inputStream = file.getInputStream();
		EasyExcel.read(inputStream, QuestionChoiceExcel.class,
				new UploadQuestionChoiceExcelListener(chapterAQuestionTypeSysAndChoicequestionService, choiceService, questionUploadVo)).sheet().doRead();
		;
		//eduCoursequestionlistInfoService.updateCourseChoiceQuestionListInfo(questionUploadVo);
		// 更新

	}

	@Override
	public List<QuestionChoiceVo> getsByMidId(Page<QuestionChoiceVo> page, QuestionQuery searcherObj) {
	List<QuestionChoiceVo> byMidId = baseMapper.getByMidId(page,searcherObj.getTypeId());
		return byMidId;
	}

	@Override
	public List<QuestionChoiceVo> getsByCourseIdAndTypeSys(Page<QuestionChoiceVo> page, QuestionQuery searcherObj) {
	List<QuestionChoiceVo> byMidId = baseMapper.getByCourseAndType(page, searcherObj.getCourseId(), searcherObj.getTypeSys());
		return byMidId;
	}

	@Override
	public List<QuestionChoiceVo> getByPaperTypeId(Page<QuestionChoiceVo> page, QuestionQuery searcherObj) {
	List<QuestionChoiceVo> byMidId = baseMapper.getByPaperTypeId(page, searcherObj.getTypeId());
		return byMidId;
	}

	@Override
	public List<QuestionChoiceVo> getByPaperTypeId(QuestionQuery searcherObj) {
		List<QuestionChoiceVo> byMidId = baseMapper.getByPaperTypeId(searcherObj.getTypeId());
		return byMidId;
	}
	
}
